package com.example.demo.controller.system;

import com.example.demo.model.system.Dict;
import com.example.demo.model.ResponseMessage;
import com.example.demo.service.system.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/dict")
public class DictController {
    @Autowired
    private DictService service;
    @RequestMapping("save")
    public ResponseMessage save(Dict dict){
        ResponseMessage responseMessage = new ResponseMessage();
        Boolean flag = service.save(dict);
        responseMessage.setFlag(flag);

        return  responseMessage;
    }

//  根据super_id查询
    @RequestMapping("selectBySuperId")
    public List<Dict> selectBySuperId(Integer super_id){return service.selectBySuperId(super_id);}

//    查询全部
    @RequestMapping("selectAll")
    public List<Dict> selectAll(){return service.selectAll();}

//    添加数据
    @RequestMapping("addDict")
    public Integer addDict(Dict dict){return service.addDict(dict);}

//    删除数据
    @RequestMapping("deleteById")
    public Boolean deleteById(Integer dict_id){return service.deleteById(dict_id)==1;}

//    更新数据
    @RequestMapping("updateById")
    public Integer updateById(Dict dict){return service.updateById(dict);}

//    模糊查询
    @RequestMapping("findDict")
    public List<Dict> findDict(String title,String code,Integer super_id){return service.findDict(title,code,super_id);}
}
